package com.ljj.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljj.pojo.Student;
import com.ljj.mapper.StudentMapper;
import com.ljj.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LJJ
 * @since 2020-07-11
 */
@Service
public class StudentServiceImpl  implements StudentService {

    @Autowired
    StudentMapper studentMapper;

    @Override
    public List<Student> queryStudentByCid(int cid) {
        return studentMapper.selectStuBycid(cid);
    }

    @Override
    public Student selectStuByid(int id) {
        return studentMapper.selectStuByid(id);
    }

    @Override
    public PageInfo<Student> queryStudentsPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Student> students = studentMapper.selectList(null);
        PageInfo<Student> studentPageInfo = new PageInfo<>(students);
        return studentPageInfo;
    }

    @Override
    public PageInfo<Student> queryStuByCidPage(int cid, Integer pageNum, Integer pageSize) {
         PageHelper.startPage(pageNum,pageSize);
        List<Student> students = studentMapper.selectStuBycid(cid);
        PageInfo<Student> studentPageInfo = new PageInfo<>(students);
        return studentPageInfo;
    }
}
